/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Classes;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Jaroslav
 */
@Entity
@Table(name = "component")
@NamedQueries({@NamedQuery(name = "Component.findByComponentId", query = "SELECT c FROM Component c WHERE c.componentId = :componentId"), 
@NamedQuery(name = "Component.findByProjectId", query = "SELECT c FROM Component c WHERE c.projectId = :projectId"), 
@NamedQuery(name = "Component.findByCompName", query = "SELECT c FROM Component c WHERE c.compName = :compName")})
public class Component implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "component_id", nullable = false)
    private Integer componentId;
    @Column(name = "project_id", nullable = false)
    private int projectId;
    @Column(name = "comp_name", nullable = false)
    private String compName;

    public Component() {
    }

    public Component(Integer componentId) {
        this.componentId = componentId;
    }

    public Component(Integer componentId, int projectId, String compName) {
        this.componentId = componentId;
        this.projectId = projectId;
        this.compName = compName;
    }

    public Integer getComponentId() {
        return componentId;
    }

    public void setComponentId(Integer componentId) {
        this.componentId = componentId;
    }

    public int getProjectId() {
        return projectId;
    }

    public void setProjectId(int projectId) {
        this.projectId = projectId;
    }

    public String getCompName() {
        return compName;
    }

    public void setCompName(String compName) {
        this.compName = compName;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (componentId != null ? componentId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Component)) {
            return false;
        }
        Component other = (Component) object;
        if ((this.componentId == null && other.componentId != null) || (this.componentId != null && !this.componentId.equals(other.componentId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Classes.Component[componentId=" + componentId + "]";
    }

}
